Dynomotion

Group: DynoMotion Message: 1445 From: quelisto Date: 7/7/2011
Subject: Using threads as programming constructs - part 2
Tom: some follow up questions.

1) Exactly how is the thread number specified when I download a program to the board? Is it the case that if I'm working on thread 2 in the C programming window, this will be thread 2 when downloaded? I ask because I have not seen any other options available to in the C programming window to specify the thread number.

2) What if thread 1 has not been downloaded before, will my thread 2 be promoted to thread 1, or will thread 1 just be treated as an empty thread?

3) Exactly how is a thread to terminate itself? Let's say I want thread 2 to terminate; in thread 2, do I issue a an EndThread(2), and then a return from main? Or do I just need to issue the EndThread(2)?

4) Can you give some more information on hte use of Mutexes to lock and unlock resources (I presume it would be used with either the persist.UserData and gather structs as these are the only global variables of which I am aware)?

5) If I'm using these boards as stand alone, will all threads automatically start up and run on their own? As I recall, I cannot use the KmotionDLL.h if I want a program to reside in the DSP board.

Thanks!
Group: DynoMotion Message: 1448 From: Tom Kerekes Date: 7/7/2011
Subject: Re: Using threads as programming constructs - part 2
Regarding:
 
#1 - Yes
 
#2 - A program in the thread #2 edit window will always be downloaded to thread #2
 
#3 - A call to ThreadDone() will never return
 
#4 - You can usually avoid the need for mutexes because if you do a WaitNextTimeSlice() you will return at the beginning of the next time slice and you will be guaranteed to execute for the next ~40us without the possibility of being interrupted.  Otherwise yes you could use the persist.UserData[100] variables as flags.
 
#5 - On the Config/Flash Screen there are enables that you can set before flashing the User Programs.  If the thread is enabled it will launch on boot up.
 
Regards
TK

--- On Thu, 7/7/11, quelisto <quelisto@...> wrote:

From: quelisto <quelisto@...>
Subject: [DynoMotion] Using threads as programming constructs - part 2
To: DynoMotion@yahoogroups.com
Date: Thursday, July 7, 2011, 6:52 AM

 
Tom: some follow up questions.

1) Exactly how is the thread number specified when I download a program to the board? Is it the case that if I'm working on thread 2 in the C programming window, this will be thread 2 when downloaded? I ask because I have not seen any other options available to in the C programming window to specify the thread number.

2) What if thread 1 has not been downloaded before, will my thread 2 be promoted to thread 1, or will thread 1 just be treated as an empty thread?

3) Exactly how is a thread to terminate itself? Let's say I want thread 2 to terminate; in thread 2, do I issue a an EndThread(2), and then a return from main? Or do I just need to issue the EndThread(2)?

4) Can you give some more information on hte use of Mutexes to lock and unlock resources (I presume it would be used with either the persist.UserData and gather structs as these are the only global variables of which I am aware)?

5) If I'm using these boards as stand alone, will all threads automatically start up and run on their own? As I recall, I cannot use the KmotionDLL.h if I want a program to reside in the DSP board.

Thanks!